Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
xod-project
Advanced tools
This is a core package that provides an API to work with XOD projects.
> Project
> Patch
> Link
> Node
> Pin
Manipulate with entities only using API functions or you can get unhandled exceptions.
Composability of functions (ramda-friendly)
That means every function take context as latest argument.
For example, getPinType(key, node)
.
Immutability of data So every function returns new copy with applied changes.
Functional style API could be used in compositions and etc, so there are no nulls or undefined values. Also there are no exceptions if you're manipulating with entities using API (don't break objects by the hand). Instead, monads like Either and Maybe from ramda-fantasy are used.
Pure functions only
Functions of xod-project
don’t have any side effects, state, or IO.
Atomic operations Each function returns a consistent part of a project (or the whole project).
Clear naming
The function name clearly informs about the expected result.
And always should begins with the action verb and ends with the subject.
The action verb may be abbreviated (like assoc
).
For example, createLink
, rebasePatch
, getPinType
, assocNode
.
Getters and Setters for primitive properties
Should looks like getSomeoneSomething
or setSomeoneSomething
.
For example, getNodeLabel
and setNodeLabel
.
Getters for lists
Should begin with list
and ends with the word in the plural form.
For example, listNodes
.
Getters for entities
In spite of the relationship of entities among themselves as nested
within each other — we obtain them using only the name of the entity,
regardless of their parents.
For example, listPatches
, listNodes
.
Getters with filtering/grouping
This is a common rule for all getters.
If getter have any filtering or grouping rule it ends with this rule.
Begin rule with prepositions by
, with
and without
.
For example, getPatchByPath
, listPatchWithNodes
.
Check functions
If function checks something and returns boolean, it looks like a question.
For example, isValidIdentifier
, hasPins
.
Property getters
Always returns a primitive value (not Monads).
Use R.prop
for returning required properties (so if user breaks object — that will be unhandled exception).
Use R.propOr
for returning optional properties and set default value (for example, R.prop('', 'label')
).
Property setters
Always returns entity with assigned new value.
Always sets value without errors, but coerce the passed argument into required type.
For example, setProjectAuthors
method should coerce value into array of strings.
So setProjectAuthors(35, project)
will return project where newProject.authors = ['35']
.
Find something and entity getters
Always returns Maybe, because it may not find anything.
For example, getNodeById(1, patch) // Maybe<Node> or Maybe<Nothing>
.
FAQs
API functions to work on XOD project state
The npm package xod-project receives a total of 2 weekly downloads. As such, xod-project popularity was classified as not popular.
We found that xod-project demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.